#
#   __init__.py.py
#   journalismManger
#
#   Created by luoxh on 2019/8/13 - 17:48.
#   Copyright © 2019 luoxh. All rights reserved.
#
import re

from src.extension.exceptions import CustomException
from src.extension.status import CustomStatus


def valid_admin_password(password):
    if not re.match('^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,16}$', password): raise CustomException(
        CustomStatus.PASSWORD_NOT_SPECIFICATIONS)


def valid_user_password(password):
    if not re.match('^(\w){6,20}$', password): raise CustomException(CustomStatus.PASSWORD_NOT_SPECIFICATIONS)


def valid_username(username):
    if not re.match('^[a-zA-Z0-9_-]{4,16}$', username): raise CustomException(CustomStatus.USERNAME_NOT_SPECIFICATIONS)
